package domain.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import domain.web.model.DetailView;
import domain.web.service.DetailService;

@Controller
@RequestMapping("data/detail")
public class DetailController {

	@Autowired
	private DetailService detailService;

	@RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
	@ResponseBody
	public List<DetailView> getDetail(@PathVariable("id") long id) {
		// DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
		// List<DetailView> views = new ArrayList<DetailView>();
		// for (int i = 0; i < 6; i++) {
		// DetailView view = new DetailView(
		// 1,
		// "Tivi LG, 1",
		// 1,
		// "Nguyen Kim",
		// "www.nguyenkim.com",
		// "http://www.sosanhgia.org/images/merchant/nguyenkim.png",
		// 1200000,
		// "productUrl",
		// "http://www.sosanhgia.org/images/product/9/1338883349-tivi-sharp-LE735M-dienmay.com-L-2.jpg",
		// dateFormat.format(new Date()));
		// views.add(view);
		// }
		// return views;
		return detailService.getViewListByProduct(id);
	}
}
